﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model.ViewModel;
using System.Collections;

namespace SYT.AliApiHandle
{
    public class HandleProInfo
    {
        //解析产品集合方法。
        public static List<ProductModel> JieXiProList(Hashtable hasht, out string Currentcount)
        {
            List<ProductModel> ProductList = new List<ProductModel>();
            ProductModel pro = new ProductModel();

            Hashtable hasht2 = (Hashtable)hasht["result"];

            //搜索的结果的产品总数量
            Currentcount = hasht2["total"].ToString();

            System.Collections.ArrayList ProList = (System.Collections.ArrayList)(hasht2["toReturn"]);
            foreach (var item in ProList)
            {
                pro = new ProductModel();
                Hashtable HashtPro = (Hashtable)item;
                //商品ID
                pro.offerId = HashtPro["offerId"] != null ? HashtPro["offerId"].ToString() : "";
                //状态。auditing：审核中；online：已上网；FailAudited：审核未通过；outdated：已过期；member delete(d)：用户删除；delete：审核删除
                pro.offerStatus = HashtPro["offerStatus"] != null ? HashtPro["offerStatus"].ToString() : "";
                //商品标题
                pro.subject = HashtPro["subject"] != null ? HashtPro["subject"].ToString() : "";
                //商品详情地址
                pro.detailsUrl = HashtPro["detailsUrl"] != null ? HashtPro["detailsUrl"].ToString() : "";
                //商品信息质量星级( 取值为1到5)。1：一星；2：二星；3：三星；4：四星；5：五星
                pro.qualityLevel = HashtPro["qualityLevel"] != null ? HashtPro["qualityLevel"].ToString() : "";
                //价格区间
                pro.priceRanges = HelpMethod.UpdateProShowPrice((ArrayList)HashtPro["priceRanges"]);
                //商品图片列表
                pro.Proimage = HelpMethod.Firstimage((ArrayList)HashtPro["imageList"]);
                //最近重发时间
                pro.gmtLastRepost = HashtPro["gmtLastRepost"] != null ? HelpMethod.ConvertTimeA(HashtPro["gmtLastRepost"].ToString()) : "1990-02-02";
                //过期日期
                pro.gmtExpire = HashtPro["gmtExpire"] != null ? HelpMethod.ConvertTimeA(HashtPro["gmtExpire"].ToString()) : "1990-02-02";
                //是否价格私密
                pro.isPriceAuthOffer = HashtPro["isPriceAuthOffer"] != null ? HashtPro["isPriceAuthOffer"].ToString() : "";
                //是否图片私密
                pro.isPicAuthOffer = HashtPro["isPicAuthOffer"] != null ? HashtPro["isPicAuthOffer"].ToString() : "";
                //是否支持网上交易。true：支持网上订购；false：不支持网上订购
                pro.isOfferSupportOnlineTrade = HashtPro["isOfferSupportOnlineTrade"] != null ? HashtPro["isOfferSupportOnlineTrade"].ToString() : "";
                //是否支持混批。true：支持混批；false：不支持混批
                pro.isSupportMix = HashtPro["isSupportMix"] != null ? HashtPro["isSupportMix"].ToString() : "";
                //供货量
                pro.amount = HashtPro["amount"] != null ? HashtPro["amount"].ToString() : "";
                //amountOnSale
                pro.amountOnSale = HashtPro["amountOnSale"] != null ? HashtPro["amountOnSale"].ToString() : "";
                //计量单位
                pro.unit = HashtPro["unit"] != null ? HashtPro["unit"].ToString() : "";
                //所属叶子类目ID
                pro.postCategryId = HashtPro["postCategryId"] != null ? HashtPro["postCategryId"].ToString() : "";

                ProductList.Add(pro);
            }
            return ProductList;
        }

    }
}
